<?php

namespace app\index\controller;

use app\index\model\PcSoftInfo;
use think\Controller;
use think\Db;

class Index extends Controller
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';

    public function index()
    {
        $cate_list_6 = Db::name('category_soft')->limit(6)->select();

        $banner_list = Db::name('banner')->select();

        $where['Status']         = ['=',PcSoftInfo::STATUS_1];
        //装机必备：
        $essential_softwares = Db::name('pc_soft_info')
            ->where($where)
            ->where('essential_softwares',1)
            ->order('OrderBy','DESC')
            ->limit(0,54)
            ->select();

        //首页十个模块
        $category_list_10 = Db::name('category_soft')
            ->limit(0,12)
            ->select();
        foreach($category_list_10 as $k=>$v){
            $category_list_10[$k]['pc_soft_4'] = PcSoftInfo::where([
                'CateId'=>$v['Id'],
                'Status'=>PcSoftInfo::STATUS_1,
            ])
                ->limit(0,5)
                ->select();
        }

        $host_search_list = Db::name('pc_soft_info')
            ->where($where)
            ->where('hot_search','=',1)
            ->order('OrderBy','DESC')
            ->limit(0,12)
            ->select();

        $recommend_list = Db::name('pc_soft_info')
            ->where($where)
            ->where('IsRecommend','=',1)
            ->order('OrderBy','DESC')
            ->limit(0,15)
            ->select();

//        dump($category_list_10);die;
        $this->assign('cate_list_6',$cate_list_6);
        $this->assign('banner_list',$banner_list);
        $this->assign('essential_softwares',$essential_softwares);
        $this->assign('category_list_10',$category_list_10);
        $this->assign('host_search_list',$host_search_list);
        $this->assign('recommend_list',$recommend_list);
        return $this->view->fetch();
    }




}
